/* #include <iostream>
#include <vector>
#include <cstring>
using namespace std;
// #define int long long
#define endl '\n'
#define P pair<int, int>
#define x first
#define y second
constexpr int maxl = 1e6 + 7;

int n, m;
int sum[maxl];
int dp[maxl];

void solve() {
  memset(dp, 0x3f, sizeof(dp));
  dp[0] = 0;

  cin >> n >> m;
  for (int i = 1, x; i <= n; i++) {
    cin >> x;
    sum[i] = x + sum[i - 1];
  }

  for (int i = 1; i <= n; i++) sum[i] += 2 * m;

  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= i; j++) {
      dp[i] = min(dp[i], dp[i - j] + sum[j]);
    }
  }

  cout << dp[n] - m << endl;
}

signed main(){
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  int t = 1;
  // cin >> t;
  while(t--) solve();
  return 0;
} */



#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int N;
    ll M;
    cin >> N >> M;

    vector<ll> inc(N+1);
    for(int i = 1; i <= N; i++){
        cin >> inc[i];
    }

    vector<ll> S(N+1, 0);
    for(int i = 1; i <= N; i++){
        S[i] = S[i-1] + inc[i];
    }


    vector<ll> C(N+1, 0);
    for(int k = 0; k <= N; k++){
        C[k] = M + S[k];
    }

    const ll INF = (ll)9e18;
    vector<ll> dp(N+1, INF);
    dp[0] = 0;

    for(int i = 1; i <= N; i++){
        for(int k = 1; k <= i; k++){
            dp[i] = min(dp[i], dp[i-k] + C[k] + M);
        }
    }

    ll ans = INF;
    for(int i = 0; i < N; i++){
        ans = min(ans, dp[i] + C[N - i]);
    }

    cout << ans << "\n";
    return 0;
}
